import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with Intellij JDEA
 * Description:写一个扑克牌
 * User:
 * Date:2022-03-14
 * Time:16:56
 */

class Card {
    public String suit;//花色
    public int rank;

    public Card(String suit, int rank) {
        this.suit = suit;
        this.rank = rank;
    }

    @Override
    public String toString() {
        return suit+"" + rank ;
    }

}

public class PuKePai {
    public static final String[] SUITS = {"♥","♠","♣","♦"};

    public static List<Card> buyCard() {
        List<Card> cards = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            for (int j = 1; j <= 13; j++) {
                String suit = SUITS[i];
                int rank = j;
                Card card = new Card(suit,rank);
                cards.add(card);
            }
        }
        return cards;
    }

    public static void shuffle(List<Card> cards) {
        //洗牌
        Random random = new Random();
        for (int i = cards.size()-1; i > 0; i--) {
            int index = random.nextInt(i);
            Card tmp = cards.get(i);
            cards.set(i,cards.get(index));
            cards.set(index,tmp);
        }
    }

    public static void main(String[] args) {

        List<Card> cardList = buyCard();
        shuffle(cardList);

        List<List<Card>> hand = new ArrayList<>();
        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();
        List<Card> hand3 = new ArrayList<>();
        hand.add(hand1);
        hand.add(hand2);
        hand.add(hand3);

        for (int i = 0; i < 17; i++) {
            for (int j = 0; j < 3; j++) {
                Card card = cardList.remove(0);
                hand.get(j).add(card);
            }
        }

        System.out.println("第二个 "+hand1);
        System.out.println("第二个 "+hand2);
        System.out.println("第三个 "+hand3);
    }
}
